package com.jeff.tianti.exception;

import com.jeff.tianti.common.ResultCode;
import com.jeff.tianti.common.dto.AjaxResult;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class HandlerExceptionController {
    @ExceptionHandler({RuntimeException.class})
    @ResponseBody
    public ResponseEntity<AjaxResult> TestExceptionHandlerExceptionResolver(Exception ex) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(false);
        ajaxResult.setMsg(ex.getMessage());
        ajaxResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
        return new ResponseEntity(ajaxResult, HttpStatus.OK);
    }

}